package com.blame.springblog.pojo.response;


import com.blame.springblog.enums.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;//业务状态码
    private String errMes;
    private Object data;



    public static Result success(Object data){
        Result result=new Result();
        result.setData(data);
        result.setErrMes("操作成功");
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        return result;
    }

    public static Result fail(String errMes,Object data){
        Result result=new Result();
        result.setData(data);
        result.setErrMes(errMes);
        result.setCode(ResultCodeEnum.FAIL.getCode());
        return result;
    }

    public static Result fail(String errMes){
        Result result=new Result();
        result.setErrMes(errMes);
        result.setCode(ResultCodeEnum.FAIL.getCode());
        return result;
    }
}
